﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.General;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InnoWeb.CEND.BL.Service
{
    public class SliderService: IService<SliderContent>
    {
        private readonly GenericRepository<SliderContent> _sliderRepository;
        private readonly IUnitOfWork _unitOfWork;

        public SliderService(IUnitOfWork unitOfWork, GenericRepository<SliderContent> sliderRepository)
        {
            this._sliderRepository = sliderRepository;
            this._unitOfWork = unitOfWork;
        }


        public IQueryable<SliderContent> GetAllElements()
        {
            return _sliderRepository.GetAll();
        }

        public SliderContent GetElementById(int id)
        {
            return _sliderRepository.GetById(id);
        }

        public void CreateElement(SliderContent entity)
        {
            _sliderRepository.Insert(entity);
        }

        public void UpdateElement(SliderContent entity)
        {
            _sliderRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _sliderRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
